package com.eleadmin.ocean.service.impl;

import com.eleadmin.common.core.web.JsonResult;
import com.eleadmin.common.system.entity.User;
import com.eleadmin.damon.utils.results.PageResult2;
import com.eleadmin.ocean.entity.OceanBulkCargoAddress;
import com.eleadmin.ocean.service.OceanBulkCargoAddressService;
import org.springframework.stereotype.Service;
import com.eleadmin.ocean.biz.OceanBulkCargoAddressBiz;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;


/**
 * 海运散货地址库服务实现类
 * @author : Doman
 * @date : 2023-10-17 15:55:16
 * @version ：1.0
 */
@Service
public class OceanBulkCargoAddressServiceImpl /*extends ServiceImpl<OceanBulkCargoAddressMapper, OceanBulkCargoAddress> */implements OceanBulkCargoAddressService {

    @Autowired
    private OceanBulkCargoAddressBiz oceanBulkCargoAddressBiz;

    @Override
    public JsonResult list(PageResult2<T> page, OceanBulkCargoAddress oceanBulkCargoAddress, User loginUser)  throws Exception{
        return oceanBulkCargoAddressBiz.list(page,oceanBulkCargoAddress,loginUser);
    }

    @Override
    public JsonResult list(OceanBulkCargoAddress oceanBulkCargoAddress, User loginUser) {
        return JsonResult.ok().setData(oceanBulkCargoAddressBiz.list(oceanBulkCargoAddress,loginUser));
    }

    @Override
    public JsonResult getById(String id) {
        return JsonResult.ok().setData(oceanBulkCargoAddressBiz.getById(id));
    }

    @Transactional
    @Override
    public JsonResult save(OceanBulkCargoAddress oceanBulkCargoAddress, User loginUser) {
        if (oceanBulkCargoAddressBiz.save(oceanBulkCargoAddress, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Transactional
    @Override
    public JsonResult update(OceanBulkCargoAddress oceanBulkCargoAddress, User loginUser) {
        if (oceanBulkCargoAddressBiz.update(oceanBulkCargoAddress, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public JsonResult remove(String id, User loginUser) {
        if (oceanBulkCargoAddressBiz.remove(id, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

    @Override
    public JsonResult listSel(OceanBulkCargoAddress oceanBulkCargoAddress, User loginUser) {
        return JsonResult.ok().setData(oceanBulkCargoAddressBiz.listSel(oceanBulkCargoAddress, loginUser));
    }

}
